package com.zzyl.controller.manager;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingLevelPageQueryDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
@Slf4j
public class NursingLevelController {
    @Autowired
    NursingLevelService nursingLevelService;

    //TODO @ApiOperation("分页查询护理等级信息")
    @GetMapping("/listByPage")
    public ResponseResult<PageBean<NursingLevelVo>> nurselevelquery(NursingLevelPageQueryDto dto) {
        PageBean<NursingLevelVo> vos = nursingLevelService.nurselevelquery(dto);
        return ResponseResult.success(vos);
    }

    //TODO @ApiOperation("插入护理等级信息")
    @PostMapping("/insert")
    public ResponseResult<Void> nurseleveladd(@RequestBody NursingLevelDto dto) {
        nursingLevelService.add(dto);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("根据ID查询护理等级信息")
    @GetMapping("/{id}")
    public ResponseResult<NursingLevelVo> nurselevelselectid(@PathVariable Long id) {
        NursingLevelVo vo = nursingLevelService.selectid(id);
        return ResponseResult.success(vo);
    }

    //TODO @ApiOperation("更新护理等级信息")
    @PutMapping("/update")
    public ResponseResult<Void> nurselevelupdate(@RequestBody NursingLevelDto dto) {
        nursingLevelService.update(dto);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("删除护理等级信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult<Void> nurseleveldelete(@PathVariable Long id) {
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("启用、禁用护理等级")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult<Void> nurselavalstatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingLevelService.status(id, status);
        return ResponseResult.success();
    }


    //TODO @ApiOperation("查询所有护理等级信息")
    @GetMapping("/listAll")
    public ResponseResult<List<NursingLevelVo>> nurselevelselectall() {
        List<NursingLevelVo> vos= nursingLevelService.selectall();
        return ResponseResult.success(vos);
    }
}